package xorm

import (
	"git.edaijia-inc.cn/edaijia/ego/elogger"

	"xorm.io/core"
)

type ELoggerXOrm struct {
	level   core.LogLevel
	showSQL bool
}

func (e *ELoggerXOrm) Debug(v ...interface{}) {
	elogger.Debug(v...)
}

func (e *ELoggerXOrm) Debugf(format string, v ...interface{}) {
	elogger.Debugf(format, v...)
}

func (e *ELoggerXOrm) Error(v ...interface{}) {
	elogger.Error(v...)
}

func (e *ELoggerXOrm) Errorf(format string, v ...interface{}) {
	elogger.Errorf(format, v...)
}

func (e *ELoggerXOrm) Info(v ...interface{}) {
	elogger.Info(v...)
}

func (e *ELoggerXOrm) Infof(format string, v ...interface{}) {
	elogger.Infof(format, v...)
}

func (e *ELoggerXOrm) Warn(v ...interface{}) {
	elogger.Warn(v...)
}

func (e *ELoggerXOrm) Warnf(format string, v ...interface{}) {
	elogger.Warnf(format, v...)
}

func (e *ELoggerXOrm) Level() core.LogLevel {
	return e.level
}

func (e *ELoggerXOrm) SetLevel(l core.LogLevel) {
	e.level = l
}

func (e *ELoggerXOrm) ShowSQL(show ...bool) {
	if len(show) == 0 {
		e.showSQL = true
		return
	}
	e.showSQL = show[0]
}

func (e *ELoggerXOrm) IsShowSQL() bool {
	return e.showSQL
}

func NewELoggerXOrm() *ELoggerXOrm {
	return &ELoggerXOrm{}
}
